package com.problem.leetcode;

public class Problem344 {
    public String reverseString(String s) {
        if (s == null) {
            return null;
        }
        char[] values = s.toCharArray();
        int    begin  = 0, end = s.length() - 1;
        while (begin < end) {
            swap(values, begin, end);
            ++begin;
            --end;
        }
        return String.valueOf(values);
    }

    public void swap(char[] strs, int begin, int end) {
        char tmp = strs[begin];
        strs[begin] = strs[end];
        strs[end] = tmp;
    }

    public static void main(String[] args) {
        String result = new Problem344().reverseString("hello");
        System.out.println(result);
    }
}
